package com.sy.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AuthInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = -3363926000416510686L;

	@SuppressWarnings("unchecked")
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {

		@SuppressWarnings("unused")
		Map map=invocation.getInvocationContext().getSession();//获取session映射
		
		if(map.get("user")==null){//如果未登陆转到登陆页面
			return Action.LOGIN;
		}
		else{
			return invocation.invoke();//如果登陆继续执行
		}
	}

}
